package nl.ceasaro.poker.texasHoldEm.game;

import nl.ceasaro.playingcards.Card;
import org.apache.commons.lang.builder.ToStringBuilder;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: cees
 * Date: Apr 12, 2007
 * Time: 10:46:31 PM
 *
 * @todo Document this class
 */
public class CommunityCards
{
   private Card flop1;
   private Card flop2;
   private Card flop3;
   private Card turn;
   private Card river;


   public Card getFlop1()
   {
      return flop1;
   }

   public void setFlop1(Card flop1)
   {
      this.flop1 = flop1;
   }

   public Card getFlop2()
   {
      return flop2;
   }

   public void setFlop2(Card flop2)
   {
      this.flop2 = flop2;
   }

   public Card getFlop3()
   {
      return flop3;
   }

   public void setFlop3(Card flop3)
   {
      this.flop3 = flop3;
   }

   public Card getTurn()
   {
      return turn;
   }

   public void setTurn(Card turn)
   {
      this.turn = turn;
   }

   public Card getRiver()
   {
      return river;
   }

   public void setRiver(Card river)
   {
      this.river = river;
   }

   public List<Card> getCards()
   {
      ArrayList<Card> cards = new ArrayList<Card>();
      if (getFlop1() != null)
      {
         cards.add(getFlop1());
      }
      if (getFlop2() != null)
      {
         cards.add(getFlop2());
      }
      if (getFlop3() != null)
      {
         cards.add(getFlop3());
      }
      if (getTurn() != null)
      {
         cards.add(getTurn());
      }
      if (getRiver() != null)
      {
         cards.add(getRiver());
      }
      return cards;
   }


   public String toString()
   {
      ToStringBuilder toStringBuilder = new ToStringBuilder(this);
      toStringBuilder.append("flop1", flop1).
              append("flop2", flop2).
              append("flop3", flop3).
              append("turn", turn).
              append("river", river);
      return toStringBuilder.toString();
   }

   /**
    * removed the draw cards from the community cards
    */
   public void reset()
   {
      flop1 = null;
      flop2 = null;
      flop3 = null;
      turn = null;
      river = null;
   }
}
